/*
 * MultiLevelPanel.java
 *
 * 
 */

package it.luigiarpino.alt2jsim.netpanel;
import it.luigiarpino.alt2jsim.core.Grafo;
import it.luigiarpino.alt2jsim.netpanel.flat.NetPanel;
import it.luigiarpino.alt2jsim.netpanel.flat.TextPanel;
import it.luigiarpino.alt2jsim.netpanel.flat.ZoomPanel;
import it.luigiarpino.alt2jsim.netpanel.nlevel.ChoiceNetPanel;
import it.luigiarpino.alt2jsim.netpanel.nlevel.CircolarPanel;
import it.luigiarpino.alt2jsim.network.N_Level_Network;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.BorderLayout;
import javax.swing.JPanel;

/**
 *
 * @author  Luigi Lorenzo Arpino 534/559
 */
public class MultiLevelPanel extends JPanel {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = -3679820939637051612L;
	private JTabbedPane jTabbedPane;
    
    /** Creates a new instance of MultiLevelPanel 
     utilizzabile solo per reti gerarchiche*/
    public MultiLevelPanel(Grafo grafo_){
        super();
        try{ 
            javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
    	} 
    	catch(Exception e) { }
        N_Level_Network net=(N_Level_Network)grafo_.getNet();
        this.jTabbedPane=new JTabbedPane();
        if (net.getNumOfLevel()==1){
            String testo=new String();
            testo="<HTML> <H1> Degenerate hierarchical network<H1>"+
            "Unable to show the network because it consists of a single level"+
            "</HTML>";
            this.add(new JLabel(testo),BorderLayout.CENTER);
        }
        else if (net.getNumOfLevel()==2){
            this.jTabbedPane.addTab("First level network",new NetPanel(net.getLevel_1_Matrix(),"Network",net.getLevel_1_Name(),NetPanel.LEVEL1NET));
            this.jTabbedPane.addTab("Entire network",new NetPanel(net.getLevel_2_Matrix(),"Network",net.getLevel_2_Name(),NetPanel.ROUTER));
            this.jTabbedPane.addTab("Zoom view",new ZoomPanel(net));
            JLabel label=new JLabel(net.getInfo());
            label.setFont(new Font(null,Font.PLAIN,20));
            this.jTabbedPane.addTab("Network info",label);
            this.jTabbedPane.addTab("Show translation",new TextPanel(grafo_));
            this.setLayout(new BorderLayout());
            this.add(this.jTabbedPane, BorderLayout.CENTER);
        }
        else if (net.getNumOfLevel()==3){
            this.jTabbedPane.addTab("First level network",new NetPanel(net.getLevel_1_Matrix(),"Netwok",net.getLevel_1_Name(),NetPanel.LEVEL1NET));
            this.jTabbedPane.addTab("Zoom second level network",new ChoiceNetPanel(net,ChoiceNetPanel.SHOW_LEVEL_2));
            this.jTabbedPane.addTab("Third level networks",new NetPanel(net.getLevel_2_Matrix(),"Network",net.getLevel_2_Name(),NetPanel.LEVEL1NET));
            this.jTabbedPane.addTab("Adjacent third level networks",new CircolarPanel(net.getLevel_2_Matrix(),net.getLevel_2_Name(),"Show third level networks adjacent to the selected","Select a network",CircolarPanel.LEVEL2NET));
            this.jTabbedPane.addTab("Zoom third level network",new ChoiceNetPanel(net,ChoiceNetPanel.SHOW_LEVEL_3)); 
            this.jTabbedPane.addTab("Adjacent nodes",new CircolarPanel(net.getLevel_3_Matrix(),net.getLevel_3_Name(),"Shows the nodes adjacent to a given node","Select a node",CircolarPanel.ROUTER));
            this.jTabbedPane.addTab("Zoom view",new ZoomPanel(net));
            JLabel label=new JLabel(net.getInfo());
            label.setFont(new Font(null,Font.PLAIN,20));
            JPanel pannello=new JPanel(new BorderLayout());
            pannello.add(label,BorderLayout.CENTER);
            this.jTabbedPane.addTab("Network info",pannello);
            this.jTabbedPane.addTab("Show translation",new TextPanel(grafo_));
            this.setLayout(new BorderLayout());
            this.add(this.jTabbedPane, BorderLayout.CENTER);
        }
        else{
            
        }
    }
    
}
